"""
基础训练值提升计算逻辑，
见：https://wiki.biligame.com/umamusume/%E5%9F%BA%E7%A1%80%E8%AE%AD%E7%BB%83%E6%8F%90%E5%8D%87%E5%80%BC
"""
import numpy as np

uma = np.asarray([1.2, 1, 1, 1.1, 1])

# A 训练基础数值
sp1 = [10, 0, 3, 0, 0]
st1 = [0, 8, 0, 6, 0]
pw1 = [0, 4, 9, 0, 0]
gj1 = [2, 0, 3, 9, 0]  # こんじょう
kg1 = [2, 0, 0, 0, 8]  # かしこさ

sp2 = [11, 0, 3, 0, 0]
pw2 = [0, 4, 10, 0, 0]
st2 = [0, 9, 0, 6, 0]
gj2 = [2, 0, 3, 10, 0]
kg2 = [2, 0, 0, 0, 9]

sp3 = [12, 0, 3, 0, 0]
pw3 = [0, 4, 11, 0, 0]

# A 训练点数 B 友情加成, C 训练效果, D 干劲
al_gy = 0
bm_skill_num = 1

bh = {"jb": 0, "A": [0, 0, 1, 0, 0], "B": [25, 0], "C": [10, 5], "D": [30, 0]}
sy = {"jb": 1, "A": [0, 0, 1, 0, 0], "B": [20, 10], "C": [10, 0], "D": [40, 0]}
al = {"jb": 0, "A": [1, 0, 0, 0, 0], "B": [20, 20*al_gy], "C": [5, 0], "D": [0, 0]}
dh = {"jb": 1, "A": [0, 0, 0, 0, 1], "B": [30, 0], "C": [0, 0], "D": [40, 15]}
my = {"jb": 0, "A": [0, 1, 1, 0, 0], "B": [30, 0], "C": [10, 5], "D": [0, 0]}
bm = {"jb": 0, "A": [0, 0, 0, 0, 2], "B": [35, 0], "C": [0, 4*bm_skill_num], "D": [0, 0]}


def upnum(yrl, spc_list):
    yrk =0.2
    A = np.asarray(yrl)
    B = 1
    C = 1
    D = 1
    N = 1
    for spc in spc_list:
        A += np.asarray(spc["A"])
        B *= 1 + (spc["B"][0] / 100 + spc["B"][1]*1.1 / 100)*spc["jb"]
        C *= (1 + spc["C"][0]/100 + spc["C"][1]/100)
        D += (spc["D"][0] + spc["D"][1])/100
        N += 0.05
    D = 1 + yrk*D
    # print("A=", A)
    # print("B=", B)
    # print("C=", C)
    # print("D=", D)
    # print("E=",uma)
    # print("N=", N)
    result = np.floor(A*uma*B*C*D*N)
    result[np.where(np.asarray(yrl)==0)]=0
    return result

if __name__ == "__main__":
    print(upnum(sp3, [al]))
    print(upnum(st2, []))
    print(upnum(pw3, [sy]))
    print(upnum(gj2, [my]))
    print(upnum(kg2, [bh,dh]))
